﻿/**

* @author admin

*/

function CheckinMarkup (bounds,number,map){
  // Now initialize all properties.
  this.bounds_ = bounds;
   
  this.map_ = map;

  // We define a property to hold the image's
  // div. We'll actually create this div
  // upon receipt of the add() method so we'll
  // leave it null for now.
  this.div_ = createDiv(number);

  // Explicitly call setMap() on this overlay
  this.setMap(map);
}
function selectMarkerLabelClass(chkins){
  	var name = "";
  		switch(chkins.toString().length){
  			case 2 :
  				name="2D";
  				break;
  			case 1 :
  				name="1D";
  				break;
  			case 3 :
  				name="3D";
  				break;
  			case 4 :
  				name="4D";
  				break;
  		}
  		return name;
  	}
function createDiv(number){
	// Create the DIV and set some basic attributes.
  var div = document.createElement('DIV');
  div.style.border = "none";
  div.style.borderWidth = "0px";
  div.style.position = "absolute";

  // Create an IMG element and attach it to the DIV.
  var p = document.createElement("P");

  p.innerHTML = number;

  
  p.setAttribute("class", "checkinTotal marker"+selectMarkerLabelClass(number)+"");
  div.appendChild(p);

  // Set the overlay's div_ property to this DIV
  return  div;
}
CheckinMarkup.prototype= new google.maps.OverlayView();

CheckinMarkup.prototype.onAdd = function() {

  // Note: an overlay's receipt of onAdd() indicates that
  // the map's panes are now available for attaching
  // the overlay to the map via the DOM.

  
	
  // We add an overlay to a map via one of the map's panes.
  // We'll add this overlay to the overlayImage pane.
  var panes = this.getPanes();
  panes.floatPane.appendChild(this.div_);
 
}

CheckinMarkup.prototype.draw = function() {
 
  // Size and position the overlay. We use a southwest and northeast
  // position of the overlay to peg it to the correct position and size.
  // We need to retrieve the projection from this overlay to do this.
  var overlayProjection = this.getProjection();

  // Retrieve the southwest and northeast coordinates of this overlay
  // in latlngs and convert them to pixels coordinates.
  // We'll use these coordinates to resize the DIV.

  var point = overlayProjection.fromLatLngToDivPixel(this.bounds_);



  // Resize the image's DIV to fit the indicated dimensions.
 
  var div = this.div_;
  div.style.left =point.x + 'px';
  div.style.top = point.y + 'px';
  div.style.zIndex = 99999999;


  
}
CheckinMarkup.prototype.show = function() {
	 
  if (this.div_) {
    this.div_.style.visibility = "visible";

  }
} 
